﻿using IDAL;
using Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DAL
{
    public class D_Size : ISize
    {
        public void Add(Size item)
        {
            CakeEntities db = new CakeEntities();
            db.Size.Add(item);
            db.SaveChanges();
        }

        public void Delete(int id)
        {
            CakeEntities db = new CakeEntities();
            db.Size.Remove(db.Size.Find(id));
            db.SaveChanges();
        }

        public Size FindById(int id)
        {
            CakeEntities db = new CakeEntities();
            return db.Size.Find(id);
        }

        public List<Size> GetAll()
        {
            CakeEntities db = new CakeEntities();
            return db.Size.ToList();
        }

        public void Updata(int id, Size item)
        {
            CakeEntities db = new CakeEntities();
            var data=db.Size.Find(id);
            if (data!=null)
            {
                data.GoodsId = item.GoodsId;
                data.Size1 = item.Size1;
                data.Price = item.Price;
                db.SaveChanges();
            }
        }
    }
}
